/**
 * 
 */
package com.cmpanyandi.elearning.wordsdriller.model;

import android.database.Cursor;

/**
 * @author wojtek
 * 
 */
public class DictionaryItem extends DictionaryDB {

    /**
     * 
     */
    private static final long serialVersionUID = 6898039857951341044L;
    public static final String CONTEXT = "context";
    public static final String DICTIONARY = "dictionary_id";
    
  
    private String context;

    public static final String[] COLUMNS = new String[] { PK, NAME, CONTEXT, DESCRIPTION, DICTIONARY };
    public static final String TABLE_NAME = "dictionary_item";
    private Dictionary dictionary;

    /**
     * Default constructor.
     */
    public DictionaryItem() {
	
    }
    
    /**
     * Constructor with long.
     * @param pk
     */
    public DictionaryItem(Long pk) {
	setPk(pk);
    }

    public Dictionary getDictionary() {
	return dictionary;
    }

    public void setDictionary(Dictionary dictionary) {
	getContentValues().put(DICTIONARY, dictionary.getPk());
	this.dictionary = dictionary;
    }

    public String getContext() {
	return context;
    }

    public void setContext(String context) {
	getContentValues().put(CONTEXT, context);
	this.context = context;
    }



    @Override
    public String getTableName() {
	return TABLE_NAME;
    }

    @Override
    public String[] getSelectionColumns() {
	return COLUMNS;
    }
    
    @Override
    public void initFromCursor(Cursor cursor) {
        super.initFromCursor(cursor);
        setContext(cursor.getString(cursor.getColumnIndexOrThrow(CONTEXT)));
	Dictionary dict = new Dictionary();
	dict.setPk(cursor.getLong(cursor.getColumnIndexOrThrow(DICTIONARY)));
        setDictionary(dict);
    }
    
    @Override
    public String getOrderBy() {
	return NAME;
    }

}
